<template>
    <div class="right-form">
        <el-tabs v-model="activeName">
            <el-tab-pane label="其它信息" name="first">
                <el-form
                        ref="elForm"
                        :model="formData"
                        size="small"
                        label-width="100px"
                        label-position="top"
                        style="height: 100%; overflow-y: auto;padding-right: 10px"

                >
                    <el-form-item label="副标题" prop="ctitle">
                        <el-input
                                v-model="formData.ctitle"
                                placeholder="请输入副标题"
                                clearable
                                :style="{ width: '100%' }"
                        >
                        </el-input>
                    </el-form-item>
                    <el-form-item label="关键字" prop="keywords">
                        <el-input
                                v-model="formData.keywords"
                                placeholder="请输入关键字"
                                clearable
                                :style="{ width: '100%' }"
                        >
                        </el-input>
                    </el-form-item>
                    <el-form-item label="描述" prop="description">
                        <el-input
                                v-model="formData.description"
                                placeholder="请输入描述"
                                clearable
                                :style="{ width: '100%' }"
                        >
                        </el-input>
                    </el-form-item>
                    <el-form-item label="标签" prop="tag">
                        <el-input
                                v-model="formData.tag"
                                placeholder="请输入标签"
                                clearable
                                :style="{ width: '100%' }"
                        ></el-input>
                    </el-form-item>
                    <el-form-item label="英文文件名" prop="filename">
                        <el-input
                                v-model="formData.filename"
                                placeholder="请输入英文文件名"
                                clearable
                                :style="{ width: '100%' }"
                        >
                        </el-input>
                    </el-form-item>
                    <el-form-item label="外链" prop="url">
                        <el-input
                                v-model="formData.url"
                                placeholder="请输入外链"
                                clearable
                                :style="{ width: '100%' }"
                        ></el-input>
                    </el-form-item>
                    <el-form-item label="排序" prop="no_order">
                        <el-input-number
                                v-model.number="formData.no_order"
                                placeholder="请输入排序"
                                clearable
                                :style="{ width: '100%' }"
                        >
                        </el-input-number>
                    </el-form-item>
                    <el-form-item label="发布时间" prop="pub_time">
                        <el-date-picker
                                v-model="formData.pub_time"
                                type="datetime"
                                placeholder="选择发布时间"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                class="full-width"
                        ></el-date-picker>
                    </el-form-item>
                    <template v-if="row.id">
                        <el-form-item label="首页推荐" prop="com_ok">
                            <el-radio-group v-model="formData.com_ok">
                                <el-radio
                                        v-for="(item, index) in com_okOptions"
                                        :key="index"
                                        :label="item.value"
                                        :disabled="item.disabled"
                                >{{ item.label }}
                                </el-radio
                                >
                            </el-radio-group>
                        </el-form-item>
                        <el-form-item label="顶置" prop="top_ok">
                            <el-radio-group v-model="formData.top_ok">
                                <el-radio
                                        v-for="(item, index) in top_okOptions"
                                        :key="index"
                                        :label="item.value"
                                        :disabled="item.disabled"
                                >{{ item.label }}
                                </el-radio
                                >
                            </el-radio-group>
                        </el-form-item>
                        <el-form-item label="是否审核" prop="is_allow">
                            <el-radio-group v-model="formData.is_allow">
                                <el-radio
                                        v-for="(item, index) in is_allowOptions"
                                        :key="index"
                                        :label="item.value"
                                        :disabled="item.disabled"
                                >{{ item.label }}
                                </el-radio
                                >
                            </el-radio-group>
                        </el-form-item>
                    </template>
                </el-form>
            </el-tab-pane>
        </el-tabs>
    </div>
</template>
<script>
    export default {
        name: "RightForm",
        props: {
            row: {
                type: Object,
                default: function () {
                    return {}
                }
            }
        },
        data() {
            return {
                activeName:"first",
                formData: {
                    ctitle: undefined,
                    keywords: undefined,
                    description: undefined,
                    tag: undefined,
                    filename: undefined,
                    url: "",
                    no_order: 0,
                    com_ok: 0,
                    top_ok: 0,
                    is_allow: 0,
                    pub_time: new Date()
                },
                com_okOptions: [
                    {
                        label: "是",
                        value: true
                    },
                    {
                        label: "否",
                        value: false
                    }
                ],
                top_okOptions: [
                    {
                        label: "是",
                        value: true
                    },
                    {
                        label: "否",
                        value: false
                    }
                ],
                is_allowOptions: [
                    {
                        label: "是",
                        value: true
                    },
                    {
                        label: "否",
                        value: false
                    }
                ]
            }
        },
        created() {
            if (this.row) {
                for (let o in this.formData) {
                    if(this.row[o] !=undefined){
                        this.formData[o] = this.row[o]
                    }
                }
            }
        },
        methods:{
            getData(){
                return this.formData
            },
            resetForm() {
                this.$refs["elForm"].resetFields();
            },
        }
    }
</script>
<style lang="scss" scoped>
    .right-form{
        background: #ffffff;
        width: 270px;
        padding: 10px 20px;
        margin-left: 0px;
        margin-bottom:0px;
        ::v-deep.el-form-item__label{
            line-height: 16px;
        }
    }
</style>
